package homework3;

import java.util.Random;
import java.util.Scanner;

public class Member {
    public static void main(String[] args) {
        int cardNum = (int) (Math.random() * (9999 - 1000 + 1)) + 1000;
        boolean flag = false;
        String id;
        String sex;
        int age;
        Scanner sc = new Scanner(System.in);
        System.out.println("请创建您的会员名:");
         id = sc.nextLine();
        if (id.length() < 3) {
            System.out.println("您输入的会员名不能少于3位");
            flag = false;
            return;
        }
            System.out.println("请输入您的性别:");
            sex = sc.nextLine();
            if (!sex.equals("男") && !sex.equals("女")) {
                System.out.println("您输入的性别有误");
                flag = false;
                return;
            }
                System.out.println("请输入您的年龄:");

                age = sc.nextInt();
                if (age < 18 || age > 40) {
                    System.out.println("您输入的年龄不符合办理会员");
                    flag = false;
                return;


                } else {
                    flag=true;
                    System.out.println("创建会员成功");

                }
        if(flag){
            System.out.println("会员名：" + id + "\n" + "性别：" + sex + "\n" + "年龄：" + age + "\n" + "随机四位会员卡号为：" + cardNum);
        }

            }


        }







